program Luch;

{$APPTYPE CONSOLE}

uses
  SysUtils;

var

k1,k2,b1,b2,y,x,r,r1,r2,m,kp,bp,a,b,x1,y1,x2,y2,x3,y3,x4,y4,f,k:real;
begin
  readln(x1,y1,x2,y2,x3,y3,x4,y4);
  m:=1;
  k:=0;
  If (x1=x2) and (y3=y4) then
    begin
      writeln('0');
      k:=1;
    end
    else
    begin
      If x1=x2 then
        begin
          f:=x1;
          x1:=y1;
          x2:=y2;
          y1:=f;
          y2:=f;
        end;
    end;
      If (x3=x4) and (y1=y2) then
    begin
      writeln('0');
      k:=1;
    end
    else
    begin
      If x3=x4 then
        begin
          f:=x3;
          x3:=y3;
          x4:=y4;
          y3:=f;
          y4:=f;
        end;
    end;
  If (y1=y2) and (y3=y4) then
    begin
      k:=1;
      Writeln(abs(y3-y1));
    end;
  If (x1<>x2) and (k=0) then
    begin
      k1:=(y1-y2)/(x1-x2);
      b1:=y1-k1*x1;

    end;
  If (x3<>x4) and (k=0) then
   begin
     k2:=(y3-y4)/(x3-x4);
      b2:=y3-k2*x3;
     end;



   If (k1=k2) and (k=0) then
   begin
     kp:=-1/k2;
     bp:=y1-kp*x1;
     a:=(b2-bp)/(kp-k2);

     If (x3-a)*(x3-x4)>0 then
       writeln((abs(y1-k2*x1-b2))/(sqrt(1+k2*k2)))
     Else
       writeln(sqrt((x1-x3)*(x1-x3)+(y1-y3)*(y1-y3)):00:04);
   end
   else
   begin
     If k=0 then
       begin
         x:=(b2-b1)/(k1-k2);

         If ((x1-x)*(x1-x2)>0) and ((x3-x)*(x3-x4)>0) then

            Writeln('0')
      else
       begin
        kp:=-1/k1;
         bp:=y3-kp*x3;
         a:=(b1-bp)/(kp-k1);

         If (x1-a)*(x1-x2)>0 then
          r1:=(abs(y3-k1*x3-b1))/(sqrt(1+k1*k1))
      Else
          r1:=-1;

        kp:=-1/k2;
        bp:=y1-kp*x1;
         a:=(b2-bp)/(kp-k2);

        If (x3-a)*(x3-x4)>0 then
          r2:=(abs(y1-k2*x1-b2))/(sqrt(1+k2*k2))
        Else
           r2:=-1;

       If (r1>0) and (r2>0) then
         begin
           If r1<r2 then
              Writeln(r1);
           If r1>r2 then
             Writeln(r2);
          end
          else begin
           m:=0;
            If (r1<0) and (r2>0) then
             begin
                Writeln(r2);
                m:=1;
             end;
            If (r1>0) and (r2<0) then
             begin
               m:=1;
               Writeln(r1);
             end;

          end;

        If m=0 then
           Writeln(sqrt((x1-x3)*(x1-x3)+(y1-y3)*(y1-y3)):00:04);






         end;
      end;
   end;
    readln;

end.
